using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using TimeTableManagement.Entities;

namespace TimeTableManagement.Mapping
{
	public class Tb_LecturerMap : EntityTypeConfiguration<Tb_Lecturer>
	{
		public Tb_LecturerMap()
		{
			// Primary Key
			this.HasKey(t => t.id);

			// Properties
			this.Property(t => t.code)
				.IsRequired()
				.HasMaxLength(10);
				
			this.Property(t => t.name)
				.IsRequired()
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("Tb_Lecturer");
			this.Property(t => t.id).HasColumnName("id");
			this.Property(t => t.code).HasColumnName("code");
			this.Property(t => t.name).HasColumnName("name");
			this.Property(t => t.id_profile).HasColumnName("id_profile");
			this.Property(t => t.id_department).HasColumnName("id_department");

			// Relationships
			this.HasRequired(t => t.Tb_Department)
				.WithMany(t => t.Tb_Lecturer)
				.HasForeignKey(d => d.id_department);
				
		}
	}
}

